// FeedbackMapper.java
package com.example.star.mapper;

import com.example.star.entity.Favorite;
import com.example.star.entity.Feedback;
import com.example.star.entity.Follow;
import com.example.star.entity.Message;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface FeedbackMapper {
    @Insert("INSERT INTO feedback (userName, adminName, message,send_time) VALUES (#{userName}, #{adminName}, #{message},NOW())")
    void insertFeedback(Feedback feedback);

    @Select("SELECT * FROM feedback")
    List<Feedback> getAllFeedbacks();

    @Select("SELECT * FROM feedback WHERE adminName = #{adminName}")
    List<Feedback> getFeedbacksByAdminName(String adminName);

    @Delete("DELETE FROM feedback WHERE id = #{id}")
    void deleteFeedbackById(int id);

    @Select("SELECT * FROM feedback LIMIT #{offset}, #{limit}")
    List<Feedback> getFeedbackByPage(@Param("offset") int offset, @Param("limit") int limit);
    @Select("SELECT COUNT(*) FROM feedback")
    int getTotalFeedback();

    // 分页查询指定用户的信息
    @Select("SELECT * FROM feedback WHERE userName = #{userName} LIMIT #{offset}, #{limit}")
    List<Feedback> getFeedbackByUserPage(@Param("userName") String userName, @Param("offset") int offset, @Param("limit") int limit);

    // 获取指定用户的总数
    @Select("SELECT COUNT(*) FROM feedback WHERE userName = #{userName}")
    int getTotalFeedbackByUser(@Param("userName") String userName);

}
